home *** CD-ROM | disk | FTP | other *** search
- Path: library.erc.clarkson.edu!rpi!not-for-mail
- From: ell@access1.digex.net (Ell)
- Newsgroups: comp.lang.c++,comp.lang.c++.moderated
- Subject: Re: [Q] Interface vs. Implementation Inheritance
- Date: 10 Feb 1996 14:32:24 -0000
- Organization: The Universe
- Sender: cppmods@netlab.cs.rpi.edu
- Approved: harkness@airmail.net
- Message-ID: <4fia9o$qm3@netlab.cs.rpi.edu>
- NNTP-Posting-Host: netlab.cs.rpi.edu
- X-Original-Date: 10 Feb 1996 06:29:30 GMT
-
- K. Lewis (lewikk@grasshopper.aud.alcatel.com) wrote:
- : When I think of substitutability, I think of subtyping. I think a
- : type is substitutable for its supertype, eg, "everywhere I use a
- : rectangle I can use a square because a square _is a_ rectangle."
-
- Not every class in C++ that is derived from a base class, and assigned to
- a base class pointer is required to, or should be a logical "is-a" subtype
- of the base class. As the C++ FAQ book points out, publicly inherited
- classes need only satisfy the promises given by, and require no more than
- the base class. [However, it is true that most publicly derived C++
- classes will in fact be logical "is-a" subtypes of the base.]
-
- The point I make is that we can also view a system as having dynamically
- substitutable parts. Whether by using a base class pointer as above in
- C++, or interface specification (contracts, or protocols) a la CLOS, and
- Smalltalk, the parts of a system may be changed during run-time
- (dynamically). Such changes may occur on both a micro (object) and macro
- (subsystem/category) level. This allows a system to fulfill more than one
- purpose, and to be robust in the face of widely varying run-time
- circumstances.
-
- With respect to C++, sometimes the thing we want to do with a system is to
- substitute one, or more of its parts with existing parts in the
- environment without regard to whether, or not the parts being swapped in
- are logical "is-a" subtypes of the base pointer being used to do the
- swapping. In C++ to do such swapping, the classes being swapped must be
- physically inherited siblings of the base class. In other languages,
- objects need only possess the protocol which allows them to be used in a
- given context (or to paraphrase one Internet contributor, to be used in a
- given "socket"). They do not have to be "is-a" subtypes of one or another
- class.
-
- Cheers,
-
- Elliott
-
- [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
- [ Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm ]
- [ Moderation policy: http://www.connobj.com/cpp/guide.htm ]
- [ Comments? mailto:c++-request@netlab.cs.rpi.edu ]
-